<?
session_start();
require_once '../../home/config.php';
$type = getValue('type','str','POST','');
$pro_id = getValue('pro_id','int','POST',0);
$rt['suc'] = 0;
switch($type){
   case 'addcart':
   $number = getValue('number','int','POST',0);
   if(isset($_SESSION['cart'][$pro_id]))
      {
       $qty = $_SESSION['cart'][$pro_id] + 1;
       if($number > 0) $qty = $number;
      }
      else
      {
       $qty=1;
      }
      $_SESSION['cart'][$pro_id]=$qty;
      $arr_pro_id = $_SESSION['cart'];
      $rt['suc'] = 1;
      $rt['num'] = count($arr_pro_id);
      echo json_encode($rt);
   break;
   case 'deletecart':
      unset($_SESSION['cart']);
      $rt['suc'] = 1;
      echo json_encode($rt);
   break;
    case 'deletecart_one':
      unset($_SESSION['cart'][$pro_id]);
      $rt['suc'] = 1;
      echo json_encode($rt);
   break;
}
?>